<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #box{width: 100px;height: 100px;position: absolute;background: red;}
        #box h2{height: 20px;font-size: 14px;background: #ccc;margin: 0;cursor: move}
    </style>
</head>
<body>
    <div id="box">
        <h2>标题</h2>
    </div>
</body>
<script>
    var obox = document.getElementById("box");

    window.onstorage = function(eve){
        console.log(eve)
        var pos = JSON.parse(localStorage.getItem("pos"))
        obox.style.left = pos.x + "px"
        obox.style.top = pos.y + "px"
    }

</script>
</html>